package hot100;

import java.util.*;

public class groupAnagrams3 {
    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String,List<String>> hash = new HashMap<>();
        for(int i = 0;i < strs.length;i++) {
            char[] tem = strs[i].toCharArray();
            Arrays.sort(tem);
            String s = new String(tem);
            List<String> demo = hash.getOrDefault(s,new ArrayList<>());
            demo.add(strs[i]);
            hash.put(s,demo);
        }
        return new ArrayList<List<String>>(hash.values());
    }
}
